jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}



function writeObj(obj){
    var description = "";

    for(var i in obj){ 

        var property=obj[i]; 

        description+=i+" = "+property+"\n";
    } 
    alert(description);
}
var TDQS = TDQS || {};
jQuery.extend( {
	adAjax : function(options) {

		var url = options.url;

		if (url.indexOf('?') != -1) {
			url += '&';
		} else {
			url += '?';
		}

		url += TDQS.PARAM_KEY_AJAX + '=true';

		var handler = options.success;

		var settings = $.extend(true,options,{
			url : url,
			type : 'POST',
			dataType : 'json',
			success : function(response) {
			
				if (response && response.status && response.status == TDQS.AJAX_STATUS_FAILTURE) {
					if (response.code < 20000) {
						// 10000<=错误码<20000时，系统异常
						if (response.message && response.message != 'null' && $.trim(response.message) != '') {
							// Session 过期或未登录错误码
							if (response.code == TDQS.SESSION_TIMEOUT) {
								window.location.href = TDQS.CONTEXT_PATH + 'jumpToLogin.jsp';
							}
						} else {
								
							errorAlert('系统异常(错误码:'+response.code+')');
							//jAlert('系统异常', '提示',function() {});
						}
	
						return;
					}
				}
	
				if (handler) {
					handler(response);
				}
			},
			error : function(response) {
				if (response
						&& response.status
						&& response.status == TDQS.AJAX_STATUS_FAILTURE) {
					if (response.code < 20000) {
						// 10000<=错误码<20000时，系统异常
						if (response.message
								&& response.message != 'null'
								&& $
										.trim(response.message) != '') {
							// Session 过期或未登录错误码
							if (response.code == TDQS.SESSION_TIMEOUT) {
								window.location.href = TDQS.CONTEXT_PATH + 'jumpToLogin.jsp';
							}
						} else {
							errorAlert('系统异常');
							//jAlert('系统异常', '提示',function() {});
						}
	
						return;
					}
				}
	
				if (handler) {
					handler(response);
				}
			}
	
		});

		$.ajax(settings);
	}

});